<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
</head>
<body>
    <script>
        //统计字符串中出现最多的字母及个数
        var str='aabbdddddrrrr';
        var value='';
        var index=0;
        var arr=str.split('');
        str=arr.sort().join();
        var reg=/(\w)\1+/g;
        str.replace(reg,function(val,item){
            if(index<val.length){
                index=val.length;
                value=item;
            }
        })
        console.log('出现最多的字母:'+value,'出现的次数:'+index);
    </script>
</body>
</html>